text: Update action enabled state correctly
authorMatthias Clasen <mclasen@redhat.com>
Sat, 27 Jun 2020 02:13:12 +0000 (22:13 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Sat, 27 Jun 2020 02:13:12 +0000 (22:13 -0400)
Take the editable property into account when updating
the emoji.insert action state, and update the action
when it changes.

Fixes: #2897
gtk/gtktext.c

index ff6fde8e5bd7a38cf5c7fc7abf9c0d041b7f130a..1ba21144c17a0ffc2741ab9d52c40e672f124f6c 100644 (file)
@@ -2627,6 +2627,7 @@ gtk_text_do_popup (GtkText *self,
   GtkTextPrivate *priv = gtk_text_get_instance_private (self);
 
   gtk_text_update_clipboard_actions (self);
+  gtk_text_update_emoji_action (self);
 
   if (!priv->popup_menu)
     {
@@ -5397,6 +5398,9 @@ gtk_text_set_editable (GtkText  *self,
       gtk_event_controller_key_set_im_context (GTK_EVENT_CONTROLLER_KEY (priv->key_controller),
                                                is_editable ? priv->im_context : NULL);
 
+      gtk_text_update_clipboard_actions (self);
+      gtk_text_update_emoji_action (self);
+
       g_object_notify (G_OBJECT (self), "editable");
     }
 }
@@ -5909,7 +5913,10 @@ gtk_text_update_clipboard_actions (GtkText *self)
 static void
 gtk_text_update_emoji_action (GtkText *self)
 {
+  GtkTextPrivate *priv = gtk_text_get_instance_private (self);
+
   gtk_widget_action_set_enabled (GTK_WIDGET (self), "misc.insert-emoji",
+                                 priv->editable &&
                                  (gtk_text_get_input_hints (self) & GTK_INPUT_HINT_NO_EMOJI) == 0);
 }